cmake_minimum_required(VERSION 3.16)
project(StudentCourseSystem)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 包含目录
include_directories(include)

# 查找MySQL
find_library(MYSQL_LIB mysqlclient)
if(NOT MYSQL_LIB)
    message(FATAL_ERROR "MySQL client library not found")
endif()

# 查找线程库
find_package(Threads REQUIRED)

# 源文件
set(SOURCES
    src/main.cpp
    src/server.cpp
    src/database.cpp
    src/auth.cpp
    src/course_manager.cpp
)

# 创建可执行文件
add_executable(${PROJECT_NAME} ${SOURCES})

# 链接库
target_link_libraries(${PROJECT_NAME}
    ${MYSQL_LIB}
    Threads::Threads
    -lpthread
)

# 设置输出目录
set_target_properties(${PROJECT_NAME} PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)

# 编译选项
target_compile_options(${PROJECT_NAME} PRIVATE
    -Wall
    -Wextra
    -pedantic
)